import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsString, MinLength, IsOptional } from 'class-validator';

export class CreateUserDto {
  @IsEmail()
  @ApiProperty({ description: '用户的电子邮件' })
  email: string;

  @IsOptional()
  @IsString()
  @ApiProperty({ description: '用户的姓名' })
  name: string;

  @IsString()
  @MinLength(6)
  @ApiProperty({ description: '用户的密码' })
  password: string;
}

export class UpdateUserDto {
  @IsEmail()
  @ApiProperty({ description: '用户的电子邮件' })
  email: string;

  @IsOptional()
  @IsString()
  @ApiProperty({ description: '用户的姓名' })
  name: string;

  @IsString()
  @MinLength(6)
  @ApiProperty({ description: '用户旧密码' })
  oldPassword: string;

  @IsString()
  @MinLength(6)
  @ApiProperty({ description: '用户新密码' })
  newPassword: string;
}

export class UserModel {
  @IsEmail()
  @ApiProperty({ description: '用户的电子邮件' })
  email: string;

  @IsOptional()
  @IsString()
  @ApiProperty({ description: '用户的姓名' })
  name: string;

  @IsString()
  @MinLength(6)
  @ApiProperty({ description: '用户的密码' })
  password: string;
}
